//
//  Anime.m
//  iMAL
//
//  Created by Stefano Pigozzi on 2/6/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "Anime.h"


@implementation Anime

- (NSString *) niceStatus
{
	return [NSString stringWithFormat:@"%@ %@/%@",
	            [self valueForKey:@"status"],
				[self valueForKey:@"watched_episodes"],
				[self valueForKey:@"episodes"]];
}

- (NSImage *) scaledImage
{
	if(_img == nil){
		NSImage * _imgunscaled = [[NSImage alloc] initWithContentsOfFile: [self valueForKey:@"image_path"]];
		_img = [_imgunscaled scaledImageToCoverSize:NSMakeSize(63.0, 90.0)];
		[_imgunscaled release];
		[_img retain];
	}
	return _img;
}

- (NSString *) niceAnimeID
{
	return [NSString stringWithFormat:@"#%@", [self valueForKey:@"anime_id"]];
}

				
- (void) setImage_path:(NSString *) path
{
	[self willChangeValueForKey:@"scaledImage"];
	[self setPrimitiveValue:path forKey:@"image_path"];
	[self didChangeValueForKey:@"scaledImage"];
}

@end
